<?php
require_once WEB_ROOT. '/application/library/Bus.php';

class Bus_User extends Bus {
    
    protected $_name = "users";
    
    protected function _init() {
        
    }
    
    public function getItemById($id){
        $Dtos = $this->select(array(
            'fields' => array(),
            'where'  => "idusers='{$id}'"
        ));
        if(count($Dtos) > 0){
            return $Dtos[0];
        }
        return false;
    }
    public function deleteItemWithId($id) {
        return $this->delete("idusers='{$id}'");
    }
    
    
    public function checkExist($username) {
        $dto = $this->select(array(
            'fields'  => array(),
            'where'   => "username='$username'"
        ));
        if(count($dto) > 0){
            return $dto[0];
        }      
        return false;  
    }
    
    public function userLogin($username, $password){
        $password = md5($password);
        $Dtos = $this->select(array(
            'where'=>"users_name ='{$username}' AND users_pass ='{$password}'"
        ));
        if(count($Dtos)>0){
            return $Dtos[0];
        }
        return false;
    }
}
?>